package com.seagox.chat.chat.controller;

import com.seagox.chat.chat.service.IChatRoomService;
import com.seagox.chat.common.ResultData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * 群聊
 */
@RestController
@RequestMapping("/room")
public class ChatRoomController {

    @Autowired
    private IChatRoomService chatRoomService;

    /**
     * 查询通过id
     */
    @GetMapping("/queryById/{id}")
    public ResultData queryById(@PathVariable String id) {
        return chatRoomService.queryById(id);
    }
    
    /**
     * 添加成员
     */
    @PostMapping("/addMember")
    public ResultData addMember(String userId, String sessionId, String data) {
        return chatRoomService.addMember(userId, sessionId, data);
    }
    
    /**
     * 移出成员
     */
    @PostMapping("/removeMember")
    public ResultData removeMember(String userId, String sessionId, String data) {
        return chatRoomService.removeMember(userId, sessionId, data);
    }
    
    /**
     * 修改群名称
     */
    @PostMapping("/modifyName")
    public ResultData modifyName(String userId, String sessionId, String name) {
        return chatRoomService.modifyName(userId, sessionId, name);
    }
    
    /**
     * 退出群聊
     */
    @PostMapping("/quit")
    public ResultData quit(String userId, String sessionId) {
        return chatRoomService.quit(userId, sessionId);
    }

}

